home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
earcd
/
devel
/
vbcc-wos-src
/
ar
/
errors.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-01
|
2KB
|
93 lines
/* $VER: ar errors.c V0.1 (31.01.98)
*
* This file is part of ar, a portable archive maintanance
* utility for normal and BSD-style archives.
* Copyright (c) 1999 Frank Wille
*
* ar is freeware and part of the portable and retargetable ANSI C
* compiler vbcc, copyright (c) 1995-99 by Volker Barthelmann.
* ar may be freely redistributed as long as no modifications are
* made and nothing is charged for it. Non-commercial usage is allowed
* without any restrictions.
* EVERY PRODUCT OR PROGRAM DERIVED DIRECTLY FROM MY SOURCE MAY NOT BE
* SOLD COMMERCIALLY WITHOUT PERMISSION FROM THE AUTHOR.
*
*
* v0.1 (31.01.99) phx
* First working version, which only supports 'q' (quick append)
* and 't' (table of contents), reads and writes normals and
* BSD-style archives. Symbol table will not be created!
* v0.0 (30.01.99) phx
* File created.
*/
#include <stdio.h>
#include <stdarg.h>
#include "ar.h"
/* error flags */
#define EF_NONE 0
#define EF_WARNING 1
#define EF_ERROR 2
#define EF_FATAL 3
static struct {
char *txt;
int flags;
} errors[] = {
"",EF_NONE,
"Out of memory",EF_FATAL, /* 01 */
"Missing archive name",EF_FATAL,
"Missing file name",EF_FATAL,
"Modifier '%c' not allowed for keyarg '%c'",EF_FATAL,
"Unknown keyarg '%c'",EF_FATAL,
"%s has a read error",EF_FATAL,
"%s: malformatted archive member %.15s",EF_ERROR,
"%s: read error at archive member %.15s",EF_ERROR,
"%s: file format not recognized",EF_ERROR,
"%s: not found in archive",EF_ERROR, /* 10 */
"%s: no such file or directory",EF_ERROR,
"creating archive %s",EF_WARNING,
"can't write archive",EF_FATAL,
"file name %s truncated to %s",EF_WARNING,
};
extern void cleanup(void);
void error(int errn,...)
/* prints errors and warnings */
{
va_list vl;
char *errtype;
int flags = errors[errn].flags;
/* print error message */
fprintf(stderr,PNAME ": ");
va_start(vl,errn);
vfprintf(stderr,errors[errn].txt,vl);
va_end(vl);
fprintf(stderr,"\n");
if (flags == EF_FATAL) {
fprintf(stderr,"Aborting.\n"); /* fatal error aborts program */
cleanup();
}
}
void ierror(char *errtxt,...)
/* display internal error and quit */
{
va_list vl;
fprintf(stderr,"\nINTERNAL ERROR: ");
va_start(vl,errtxt);
vfprintf(stderr,errtxt,vl);
va_end(vl);
fprintf(stderr,".\nAborting.\n");
cleanup();
}